package com.haq.housesystem.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.haq.housesystem.bean.HousesOrient;
import com.haq.housesystem.bean.HousesType;
import com.haq.housesystem.dao.HousesOrientDao;
import com.haq.housesystem.service.HousesOrientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class HousesOrientServiceImpl implements HousesOrientService {
    @Autowired
    HousesOrientDao housesOrientDao;

    @Override
    public void insert(HousesOrient housesOrient) {
        housesOrientDao.insert(housesOrient);
    }

    @Override
    public void update(HousesOrient housesOrient) {
        housesOrientDao.update(housesOrient);
    }

    @Override
    public void delete(int orientId) {
        housesOrientDao.delete(orientId);
    }

    @Override
    public void deleteByIds(int[] orientIds) {
        housesOrientDao.deleteByIds(orientIds);
    }

    @Override
    public List<HousesOrient> selectAll() {
        List<HousesOrient> list=housesOrientDao.selectAll();
        return list;
    }

    @Override
    public HousesOrient selectById(int orientId) {
        HousesOrient housesOrient=housesOrientDao.selectById(orientId);
        return  housesOrient;
    }

    @Override
    public List<HousesOrient> selectByName(String orientName) {
        List<HousesOrient> list=housesOrientDao.selectByName(orientName);
        return list;
    }

    @Override
    public int getNumer() {
        return 0;
    }

    @Override
    public PageInfo<HousesOrient> selectAllByPageInfo(int curPage, int size) {
        PageHelper.startPage(curPage, size);
        List<HousesOrient> list = housesOrientDao.selectAll();
        PageInfo<HousesOrient> pageInfo=new PageInfo<HousesOrient>(list);
        return pageInfo;
    }

    @Override
    public PageInfo<HousesOrient> selectByNameByPageInfo(int curPage, int size, String typeName) {
        PageHelper.startPage(curPage, size);
        List<HousesOrient> list = housesOrientDao.selectByName(typeName);
        PageInfo<HousesOrient> pageInfo=new PageInfo<HousesOrient>(list);
        return pageInfo;
    }
}

